package java_thinking.unit_21.Exercise.atomic;

import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicReferenceArray;

/**
 * @Desc:   支持对底层引用数组变量的原子操作
 * @author: cww
 * @DateTime: 2019-07-28 17:50
 */

public class AtomicReferenceArrayTest {
    public static void main(String[] args) {
        AtomicReferenceArray<Obj> array = new AtomicReferenceArray<>(10);
        Obj obj = new Obj();
        array.set(2,obj);

        AtomicReference<Obj> reference = new AtomicReference<>(obj);
        obj.setI(66);


    }
}


class Obj{
    int i = 2;
    long x = 5L;

    public int getI() {
        return i;
    }

    public void setI(int i) {
        this.i = i;
    }

    public long getX() {
        return x;
    }

    public void setX(long x) {
        this.x = x;
    }
}
